package mobilesmil.activity.composer;

import mobilesmil.activity.R;
import mobilesmil.data.SmilResource;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
/**
 * Provides a simple form for selecting the type of {@link SmilResource} the user wishes to add to their {@link SmilDataSet}.
 * Types are audio, image, text, and video.
 * @author Ryan Ware
 *
 */
public class AddNewResourceActivity extends Activity {
	
	@Override
    public void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        setContentView(R.layout.add_new_resource);
        ComposerActivity.setEditingResource(null);
        ComposerActivity.setCreatingNewResource(true);
        
        findViewById(R.id.btnAddAudio).setOnClickListener(new View.OnClickListener() {
    		public void onClick(View view) {
        		ComposerActivity.setNewResourceType(SmilResource.TYPE_AUDIO);
        		setResult(RESULT_OK, getIntent());
        		finish(); // close this Activity
        	}
        });
        
        findViewById(R.id.btnAddImage).setOnClickListener(new View.OnClickListener() {
    		public void onClick(View view) {
    			ComposerActivity.setNewResourceType(SmilResource.TYPE_IMAGE);
        		setResult(RESULT_OK, getIntent());
        		finish(); // close this Activity
        	}
        });
        
        findViewById(R.id.btnAddText).setOnClickListener(new View.OnClickListener() {
    		public void onClick(View view) {
    			ComposerActivity.setNewResourceType(SmilResource.TYPE_TEXT);
        		setResult(RESULT_OK, getIntent());
        		finish(); // close this Activity
        	}
        });
        
        findViewById(R.id.btnAddVideo).setOnClickListener(new View.OnClickListener() {
    		public void onClick(View view) {
    			ComposerActivity.setNewResourceType(SmilResource.TYPE_VIDEO);
        		setResult(RESULT_OK, getIntent());
        		finish(); // close this Activity
        	}
        });
	}
	
	@Override
	public void onBackPressed() {
		// if creating a new SMIL file, will send user back to General Properties form
		if(ComposerActivity.isCreatingNewSmil()) {
			setResult(ComposerActivity.RESULT_CODE_NEW_BACK_BUTTON);
		}
		finish();
	}

}
